﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MvcSiteMapProvider.Extensibility;
using web.data.entities;

namespace web.bussines
{
    public class staticMapDynamicNodeProvider : DynamicNodeProviderBase
    {
        public override IEnumerable<DynamicNode> GetDynamicNodeCollection()
        {
            using (var data = new baseEntities())
            {
                List<DynamicNode> list_node = new List<DynamicNode>();
                page_static_service staSvc = new page_static_service();
                int? languageId;
                languageId = web.component.global_const.LANGUAGE_ID_DEFAULT;   //default language 1 (vi) if null language
                var list_statis = staSvc.page_static_list_by_status(true,true, languageId??1);
                foreach (var item in list_statis)
                {
                    DynamicNode node = new DynamicNode();
                    node.Title = item.page_name;
                    node.Key = "staticId_" + item.page_id;
                    node.RouteValues.Add("link", item.link);
                    node.RouteValues.Add("id", item.page_id);
                    node.Action = "detail";
                    node.Controller = "pageStatic";
                    node.Route = "page_static";

                    list_node.Add(node);

                }
                return list_node;
            }           
        }     
    }
}
